package 力扣.数组.二维数组;

import java.util.Arrays;

public class 转置矩阵867 {
    public static void main(String[] args) {
//        int [][] ints = {{1,2,3},{4,5,6},{7,8,9}};
//        int [][] ints = {{1,2,3},{4,5,6}};
        int [][] ints = {{}};
        int[][] transpose = transpose(ints);
        System.out.println(Arrays.deepToString(transpose));
    }

    /**
     * 转置矩阵：行变列 列变行
     * @param matrix
     * @return
     */
    public static int[][] transpose(int[][] matrix) {
        int r = matrix.length;
        int c = matrix[0].length;
        int [][] re = new int[c][r];
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                re[j][i] = matrix[i][j];
            }
        }
        return  re;
    }

}
